/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.unirio.ticketnator.dao;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Map;

/**
 *
 * @author adm.Frade
 */
public class LoginDAO {
    
	private static final long serialVersionUID = 1L;
   
        
	public LoginDAO(){
		
	}
	
	public static boolean Validate(String userName,String password) {
		Connection c = SupportDAO.getConnection();
		boolean resposta = false;
		
		if(c == null)
			return resposta;
		
		try
		{
			PreparedStatement ps = c.prepareStatement("SELECT NOME_USUARIO FROM TB_USUARIO WHERE EMAIL = ? AND SENHA = ?" );
			ps.setString(1, userName);
			ps.setString(2, password);
			
			ResultSet rs = ps.executeQuery();
			
			while(rs.next())
			{
				 userName = rs.getString(1);
				 resposta = true;
			}
		
                     
		}catch (SQLException e)
		{
			SupportDAO.log(e.getMessage());
			resposta = false;
		}
		
		return resposta;
				
	}
}
